﻿using System;
using System.Diagnostics;

namespace FastClone.Console
{
    internal class Program
    {
        static void Main()
        {
            for (int i = 0; i < 10; i++)
                Benchmark();

            System.Console.WriteLine("press any key...");
            System.Console.ReadKey();
        }

        static void Benchmark()
        {
            Process original = Process.GetCurrentProcess();

            StopwatchToConsole("Cloner", () =>
            {
                for (int i = 0; i < 100000; i++)
                    Cloner.Clone(original);
            });
        }

        static long Stopwatch(Action action)
        {
            Stopwatch stopwatch = System.Diagnostics.Stopwatch.StartNew();
            action.Invoke();
            return stopwatch.ElapsedMilliseconds;
        }

        public static void StopwatchToConsole(string message, Action action)
        {
            long result = Stopwatch(action);
            System.Console.WriteLine("{0}: {1}", message, result);
        }
    }
}